package com.api.springdemo.controller;

import com.api.springdemo.entity.User;
import com.api.springdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;
    @GetMapping("get")
    public String getUser(Integer id) {
        return userService.getById(id).toString();
    }

    @GetMapping("save")
    public String saveUser(User user) {
        userService.save(user);
        return "success";
    }

    @GetMapping("selectPage")
    public String selectPage(Integer page,Integer size) {
        return userService.selectPage(page,size).toString();
    }
}
